#include "UtilityPCH.h"
#include "UT_ScenePrimitiveBase.h"
#include "UT_Intersection.h"
#include "UT_Log.h"

using namespace Utility;

uint32_t UT_ScenePrimitiveBase::m_suiNextPrimitiveId = 1;
//----------------------------------------------------------------------------
UT_ScenePrimitiveBase::~UT_ScenePrimitiveBase()
{

}
//----------------------------------------------------------------------------
bool UT_ScenePrimitiveBase::CanIntersect() const
{
	return true;
}
//----------------------------------------------------------------------------
void UT_ScenePrimitiveBase::Refine(UT_TVector<UT_SmartPointer<UT_ScenePrimitiveBase> > &refined) const
{
	GfxWriteLog(LOG_D_DEFAULT_ERROR,"Unimplemented Primitive::Refine() method called!");
}
//----------------------------------------------------------------------------
void UT_ScenePrimitiveBase::FullyRefine(UT_TVector<UT_SmartPointer<UT_ScenePrimitiveBase> > &refined) const
{
	UT_TVector<UT_SmartPointer<UT_ScenePrimitiveBase> > todo;
	todo.AddLast(const_cast<UT_ScenePrimitiveBase *>(this));

	while (todo.GetSize())
	{
		// Refine last primitive in todo list
		UT_SmartPointer<UT_ScenePrimitiveBase> prim = todo.GetLast();
		todo.RemoveLast();
		
		if (prim->CanIntersect())
			refined.AddLast(prim);
		else
			prim->Refine(todo);
	}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
